<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Models\Invoice\Title;

class CreateInvoiceTitlesTable extends Migration
{

    const TABLE = Title::TABLE;

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        !Schema::hasTable(self::TABLE) &&
        Schema::create(self::TABLE, function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->uuid('app_user_id')->default('')->index();
            $table->json('value')->nullable();
            $table->tinyInteger('type')->default(0);
            $table->boolean('is_default')->default(false);
        });
        DB::statement("alter table `".self::TABLE."` comment '发票抬头';");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists(self::TABLE);
    }
}
